<include file="Public:header" />
<style>
table tbody tr{cursor:move;}
</style>
<div class="container">
	<div class="page-header">
		<h4>{:L('SYSTEM_SETTING')}</h4>
	</div>
	<include file="Public:alert" />
	<div class="tabbable">
		<ul class="nav nav-tabs">
			<li><a href="{:U('setting/defaultInfo')}">{:L('BASIC_SYSTEM_SETTING')}</a></li>
			<li><a href="{:U('setting/smtp')}">{:L('SMTP_SETTING')}</a></li>
			<li class="active"><a href="{:U('setting/fields')}">{:L('CUSTOMIZING_FIELDS_SETTING')}</a></li>		
			<li><a href="{:U('navigation/setting')}">{:L('SYSTEM_NAVIGATION_SETTING')}</a></li>
			<li><a href="{:U('setting/weixin')}">{:L('WHCHAT_SETTING')}</a></li>
		</ul>
	</div>
	<div class="row">
		<div class="span2 knowledgecate">
			<ul class="nav nav-list">
				<li class="active">
					<a href="javascript:void(0);" onclick="color_box()">{:L('CUSTOMIZING_FIELDS_SETTING')}</a>
				</li>
				<li><a <if condition="$_GET['model'] eq 'customer' || $_GET['model'] eq ''">class="active"</if> href="{:U('setting/fields', 'model=customer')}"><i class="icon-chevron-right"></i>{:L('CUSTOMER_FIELDS_SETTING')}</a></li>
				<li><a <if condition="$_GET['model'] eq 'business'">class="active"</if>  href="{:U('setting/fields', 'model=business')}"><i class="icon-chevron-right"></i>{:L('BUSINESS_FIELDS_SETTING')}</a></li>
				<li><a <if condition="$_GET['model'] eq 'porduct'">class="active"</if>  href="{:U('setting/fields', 'model=product')}"><i class="icon-chevron-right"></i>{:L('PRODUCT_FIELDS_SETTING')}</a></li>
				<li><a href="{:U('knowledge/category')}" ><i class="icon-chevron-right"></i>{:L('KNOWLEDGE_CATEGORY')}</a></li>
			</ul>
		</div>
		<form action="{:U('setting/businessstatusdelete')}" method="post">
			<div class="span10">
				<p><div class="bulk-actions align-left">
					<input type="submit" class="btn" value="{:L('DELETE')}"/> &nbsp; <a class="btn" id="sort_btn">{:L('SAVE_ORDER')}</a>
					<div class="pull-right">
						<a class="btn btn-primary" id="add">{:L('ADD_STATE')}</a>
					</div>
				</div></p>
			</div>
			<div class="span10">
				<table class="table table-hover" width="95%" border="0" cellspacing="1" cellpadding="0">
					<notempty name="statusList">
					<thead>
						<tr>
							<th width="10%"><input type="checkbox" name="check_all" id="check_all" class="check_all"/> &nbsp;</th>
							<th width="20%">{:L('STATE_NAME')}</th>
							<th width="50%">{:L('STATE_DESCRIBE')}</th>
							<th width="20%">{:L('OPERATING')}</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="4">
								<div class="span8"><span style="color: rgb(243, 40, 12);">{:L('PROMPT')}</span></div>
							</td>
						</tr>
					</tfoot>
					<tbody>
						<volist name="statusList" id="vo">
							<tr>
								<td><if condition="$vo['is_end'] neq 1"><input type="checkbox" class="list" name="status_id[]" value="{$vo.status_id}"/></if>
								</td>
								<td>{$vo.name}</td>
								<td>{$vo.description}</td>
								<td><a class="edit" href="javascript:void(0)" rel="{$vo.status_id}">{:L('EDIT')}</a><if condition="$vo['is_end'] neq 1"> &nbsp; &nbsp;<a class="delete" href="javascript:void(0)" rel="{$vo.status_id}">{:L('DELETE')}</a></if></td>
							</tr>
						</volist>
					</tbody>
					<else />
						<tr>
							<td>{:L('EMPTY_TPL_DATA')}</td>
						</tr>
					</notempty>
				</table>
			</div> 
		</form>
	</div>
<div class="hide" id="dialog-add" title="{:L('ADD_STATE')}">loading...</div>
<div class="hide" id="dialog-edit" title="{:L('MODIFY_THE_STATE_OF')}">loading...</div>
<div class="hide" id="dialog-delete" title="{:L('DELETE_THE_STATE_OF')}">loading...</div>
</div>
<script type="text/javascript">	
$("#dialog-add").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-edit").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	position: ["center",100]
});
$("#dialog-delete").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	position: ["center",100]
});

$("table tbody").sortable({connectWith: "table tbody"});

$(function(){
	$("#check_all").click(function(){
		$("input[class='list']").prop('checked', $(this).prop("checked"));
	});
	$("#add").click(function(){
		$('#dialog-add').dialog('open');
		$('#dialog-add').load('{:U("setting/businessstatusadd")}');
	});
	$(".edit").click(function(){
		var id = $(this).attr('rel');
		$('#dialog-edit').dialog('open');
		$('#dialog-edit').load('{:U("setting/businessstatusedit","id")}'+id);
	});
	$(".delete").click(function(){
		var id = $(this).attr('rel');
		$('#dialog-delete').dialog('open');
		$('#dialog-delete').load('{:U("setting/businessstatusdelete","id")}'+id);
	});
	$("#sort_btn").click(
		function() {
			position = [];
			$.each($(".list"), function(i, item){position.push(item.value)});
			$.get('{:U("setting/businessstatussort")}',{postion:position.join(',')}, function(data){
				if (data.status == 1) {
					$(".page-header").after('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>' + data.info + '</div>');
				} else {
					$(".page-header").after('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>' + data.info + '</div>');
				}
			}, 'json');
		}	
	);
})
</script>
<include file="Public:footer" />